package xyz.wanhongtao.smtpclient.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import xyz.wanhongtao.smtpclient.object.properties.ResultEnum;
import xyz.wanhongtao.smtpclient.object.vo.Result;

/**
 * @author wanghongtao <wanghongtao05@kuaishou.com>
 * Created on 2023-07-03
 */
@Slf4j
@RestControllerAdvice
public class ExceptionHandler {
    @org.springframework.web.bind.annotation.ExceptionHandler(CustomException.class)
    public Result<?> handCustomException(CustomException e) {
        return Result.error(e.code,e.message);
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    public Result<?> handCustomException(Exception e) {
        return Result.error(ResultEnum.ERROR);
    }
}
